package org.gl.training.gwt.server.utils;

import java.util.ArrayList;
import java.util.List;

import org.gl.training.gwt.shared.model.UserVO;
import org.gl.training.planner.model.User;

public class UserVOUtils {

	public static List<UserVO> getUserVOs(List<User> users) {
		List<UserVO> userVOList = new ArrayList<UserVO>();
		for (User user : users) {
			UserVO userVO = getUserVO(user);
			userVOList.add(userVO);
		}
		return userVOList;
	}

	public static UserVO getUserVO(User user) {
		if (user == null) {
			return null;
		}

		UserVO userVO = new UserVO();
		userVO.setId(user.getId());
		userVO.setUserName(user.getUserName());
		userVO.setFullName(user.getFullName());
		userVO.setEmail(user.getEmail());
		userVO.setUserStatus(user.getUserStatus());
		userVO.setPassword(user.getPassword());
		userVO.setAdmin(user.isAdmin());
		return userVO;
	}

	public static User getUser(UserVO userVO) {
		User user = new User();
		user.setUserName(userVO.getUserName());
		user.setFullName(userVO.getFullName());
		user.setEmail(userVO.getEmail());
		user.setPassword(userVO.getPassword());
		user.setNotes(userVO.getNotes());
		return user;
	}
}
